<?php

/**
 * Form Date Validator class, verify the format of a date : dd/mm/yyyy
 *
 * @author Mathieu Pheulpin - sokaru91@gmail.com
 *
 */
class Mac_Form_Validator_Email extends Mac_Form_Validator_Abstract
{
    private $errors = array(
        'format' => 'L\'email est au mauvais format'
    );

    public function isValid($value, array $context)
    {
        $matches = array();
        if (!preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,10}$#', $value)) {
            $this->setMessage($this->errors['format']);
            return false;
        }
        return true;
    }
}